package com.zrrd.javaSEPlus._02_enum;

import java.util.Arrays;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo03
 * @description
 * @create 2023/11/11 18:42
 */
public class EnumMethod {
    public static void main(String[] args) {
        //获取枚举项的名称
        System.out.println(myEnum.SPRING.name());
        //返回枚举项在枚举类中的索引值
        System.out.println(myEnum.SPRING.ordinal());
        int i = myEnum.SPRING.compareTo(myEnum.AUTUMN);
        System.out.println(i);
        //根据指定的字符串(name)返回指定的枚举类type的枚举项。如果为null，抛异常，如果没有，抛异常。
        myEnum me = Enum.valueOf(myEnum.class, "SPRING");
        System.out.println(me);

        myEnum[] values = myEnum.values();
        System.out.println(Arrays.toString(values));
    }
}
enum myEnum{
    SPRING,SUMMER,AUTUMN,WINTER;


}
enum myEnum02{
    春天,夏天,秋天,冬天;
}